import { connect } from 'react-redux'
import { actions } from 'react-native-navigation-redux-helpers'

import SideBar from '../components/sideBar'
import { closeDrawer } from '../redux/actions/drawer'

const {
  pushRoute,
} = actions

const mapStateToProps = state => ({
  navigation: state.cardNavigation,
})

const bindAction = (dispatch) => ({
  onPersonPress: (navigation) => {
    dispatch(closeDrawer())
    dispatch(pushRoute({key: 'person'}, navigation.key))
  },
  onAccountPress: (navigation) => {
    dispatch(closeDrawer())
    dispatch(pushRoute({key: 'account'}, navigation.key))
  },
})

export default connect(mapStateToProps, bindAction)(SideBar)
